<template>
	<view class="content">
		<view v-if="type==1" class="block list-block">
			<view class="model" v-for="(item,index) in list" :key="item.id">
				<view v-if="item.state==1" class="ranking-block">预定中</view>
				<view v-if="item.state==2" class="ranking"></view>
				<view v-if="item.state==3" class="ranking-blockgrey">已结束</view>

				<view class="list-item">
					<image mode="aspectFill" :src="item.coverUrl" class="cover-photo"></image>
					<view class="info">
						<view class="title">{{item.title}}</view>
						<view class="incount">
							<view class="module">企业{{item.qyCount}}家</view>
							<view class="module">职位{{item.zwCount}}个</view>
							<!-- <view class="module">岗位{{item.gwCount}}个</view> -->
						</view>
					</view>
				</view>
				<view class="lower">
					<view class="time">{{item.eventTimeStart}}至{{item.eventTimeEnd}}
					</view>
					<view @click="navigate('/page_other/job_hunting/job_fair/detail?id='+item.id)" class="btn">
						进入会场
					</view>
				</view>
			</view>
		</view>
		<view v-if="type==2" class="block list-block">
			<view class="model" v-for="(item,index) in list" :key="item.id">
				<view v-if="item.state==1" class="ranking-block">预定中</view>
				<view v-if="item.state==2" class="ranking"></view>
				<view v-if="item.state==3" class="ranking-blockgrey">已结束</view>
				<view class="list-item">
					<image mode="aspectFill" :src="item.coverUrl" class="cover-photo"></image>
					<view class="info">
						<view class="title">{{item.title}}</view>
						<view class="incount">
							<view class="module">企业{{item.qyCount}}家</view>
							<view class="module">职位{{item.zwCount}}个</view>
							<!-- <view class="module">岗位{{item.gwCount}}个</view> -->
						</view>
					</view>
				</view>
				<view class="lower">
					<view class="time">{{item.eventTimeStart}}至{{item.eventTimeEnd}}
					</view>
					<view @click="navigate('/page_other/job_hunting/job_fair/detail?id='+item.id)" class="btn">
						进入会场
					</view>
				</view>
			</view>
		</view>
		<view v-if="type==3" class="block list-block">
			<view class="model" v-for="(item,index) in list" :key="item.id">
				<view v-if="item.state==1" class="ranking-block">预定中</view>
				<view v-if="item.state==2" class="ranking"></view>
				<view v-if="item.state==3" class="ranking-blockgrey">已结束</view>
				<view class="list-item">
					<image mode="aspectFill" :src="item.coverUrl" class="cover-photo"></image>
					<view class="info">
						<view class="title">{{item.title}}</view>
						<view class="incount">
							<view class="module">企业{{item.qyCount}}家</view>
							<view class="module">职位{{item.zwCount}}个</view>
							<!-- <view class="module">岗位{{item.gwCount}}个</view> -->
						</view>
					</view>
				</view>
				<view class="lower">
					<view class="time">
						{{item.eventTimeStart}}至{{item.eventTimeEnd}}
					</view>
					<view @click="navigate('/page_other/job_hunting/job_fair/detail?id='+item.id)" class="btn">
						进入会场
					</view>
				</view>
			</view>
		</view>
		<!-- 底部加载提示 -->
		<view v-else-if="list.length>0" style="text-align: center;">没有更多了哦</view>
		<view v-else style="text-align: center;">暂无数据</view>
	</view>
</template>

<script>
	import {
		findAllByCrtTimeApi
	} from '@/api/job.js';
	export default {
		data() {
			return {
				type: null,
				list: [],
			}
		},
		methods: {
			navigate(url) {
				uni.navigateTo({
					url
				})
			},
			findAllByCrtTime() {
				findAllByCrtTimeApi({
					sceneType: this.type
				}).then((res) => {
					this.list = res;
					console.log(this.list)
				}).catch((res) => {
					console.log(res)
				})
			},
			resolvingDate(date) {
				if (!date) {
					return;
				}
				//date是传入的时间
				let d = new Date(date);
				let month = (d.getMonth() + 1) < 10 ? '0' + (d.getMonth() + 1) : (d.getMonth() + 1);
				let day = d.getDate() < 10 ? '0' + d.getDate() : d.getDate();
				let hours = d.getHours() < 10 ? '0' + d.getHours() : d.getHours();
				let min = d.getMinutes() < 10 ? '0' + d.getMinutes() : d.getMinutes();
				let sec = d.getSeconds() < 10 ? '0' + d.getSeconds() : d.getSeconds();
				let times;
				times = d.getFullYear() + '-' + month + '-' + day + ' ' + hours + ':' + min;
				return times
			}
		},
		onLoad(e) {
			this.type = e.type
			uni.setNavigationBarTitle({
				title: e.title + '招聘会'
			})
			this.findAllByCrtTime();
		}
	}
</script>

<style lang="scss">
	page {
		background: #FAFAFA;
	}

	.content {
		width: 100%;
		padding: 30rpx;

		.block {
			width: 100%;
			margin-bottom: 40rpx;
			position: relative;

			.search {
				width: 100%;
				height: 70rpx;
				padding: 0 20rpx;
				font-size: 28rpx;
				background: #F3F3F3;
				border-radius: 50rpx;
			}

			.iconfont.icon-sousuo {
				position: absolute;
				transform: translate(0, -50%);
				right: 10rpx;
				top: 50%;
				font-size: 42rpx;
				font-weight: bold;
				color: #999;
			}
		}

		.block.list-block {
			display: flex;
			flex-direction: column;
			margin-bottom: 0;
			width: 100%;
			height: 100%;

			.model {
				width: 100%;
				height: 100%;
				border-radius: 20rpx;
				background: #fff;
				box-shadow: 0 0 10px 0 #efefef;
				padding: 20rpx;
				flex-direction: row;
				margin-bottom: 30rpx;
				border-bottom: 1px solid #efefef;
				position: relative;

				.ranking-block {
					display: flex;
					padding: 6rpx 0 0 16rpx;
					color: #fff;
					position: absolute;
					font-size: 28rpx;
					top: 0;
					left: -2px;
					width: 160rpx;
					height: 60rpx;
					background: url('https://job-1306862033.cos.ap-chengdu.myqcloud.com/miniprogram-static/job_hunting/job_fair/ongoing.png') no-repeat center;
					background-size: 100% 100%;
					line-height: 50rpx;
					padding-left: 36rpx;
				}

				.ranking {
					position: absolute;
					width: 160rpx;
					height: 60rpx;
					background: url('https://www.mashangjiuye.com/api/file/91885/zphing.png') no-repeat center;
					background-size: 100% 100%;
					line-hseight: 50rpx;
					padding-left: 36rpx;
				}

				.ranking-blockgrey {
					display: flex;
					padding: 6rpx 0 0 16rpx;
					color: #fff;
					position: absolute;
					font-size: 28rpx;
					top: 0;
					left: -2px;
					width: 160rpx;
					height: 60rpx;
					background: url('https://job-1306862033.cos.ap-chengdu.myqcloud.com/miniprogram-static/job_hunting/job_fair/end.png') no-repeat center;
					background-size: 100% 100%;
					line-height: 50rpx;
					padding-left: 36rpx;
				}

				.list-item {
					height: 90px;
					border-bottom: 1px solid #efefef;
					display: flex;

					.cover-photo {
						width: 140px;
						height: 80px;
						background: #efefef;
						margin-right: 20rpx;

					}

					.info {
						width: calc(100% - 195rpx);
						display: flex;
						flex-direction: column;

						.title {
							width: 100%;
							display: -webkit-box;
							-webkit-box-orient: vertical;
							-webkit-line-clamp: 2;
							overflow: hidden;
							font-weight: bold;
							font-size: 30rpx;
							color: #313131;
						}

						.host,
						.time {
							width: 100%;
							font-size: 26rpx;
							color: #999;
							overflow: hidden;
							text-overflow: ellipsis;
							white-space: nowrap;
						}

						.time {
							margin-top: 10rpx;
						}

						.host {
							margin-top: 10rpx;
						}

						.incount {
							display: flex;
							color: #909090;
							font-size: 28rpx;
							margin-top: 50rpx;

							.module {
								width: 130rpx;
								font-size: 24rpx;
							}

						}
					}
				}

				.lower {
					display: flex;
					margin-top: 10rpx;

					.time {
						color: #909090;
						font-size: 24rpx;
						margin-top: 15rpx;
					}

					.btn {
						width: 180rpx;
						height: 60rpx;
						line-height: 58rpx;
						border-radius: 15rpx;
						text-align: center;
						color: #fff;
						background-color: #ff7626;
						font-size: 28rpx;
						margin-left: 20px;
					}
				}

			}

			.list-item:last-child {
				margin: 0;
			}
		}
	}
</style>
